package uk.co.revisual.domino.errors
{
	public class StateModelError extends Error
	{
		public static const MULTIPLE_NODES:int = 0;
		public static const NO_CLASS_ATTRIBUTE:int = 1;
		public static const MULTIPLE_CLASS_ATTRIBUTES:int = 2;
		public static const NULL_DATA:int = 3;
		public static const STATE_NOT_FOUND:int = 4;
		public static const NULL_STATENAME_PASSED:int = 5;
		public static const MULTIPLE_STATES:int = 6;
		public static const NULL_NOTENAME_PASSED:int = 7;
		private static const MSGS:Array = [	"There are multiple instances of this node",
											"No class attribute declared for this node",
											"There are multiple instances of the class attribute",
											"Either no FSM data has been set, or it is not XML",
											"This state has not been declared in the FSM data",
											"The statename passed was null",
											"There are multiple states with this name declared",
											"The notename passed was null"];
		
		public var statename:String;
		public var nodename:String;
		public var id:int;
		
		public function StateModelError( id:int, statename:String = null, nodename:String = null  )
		{
			this.statename = statename;
			this.nodename = nodename;
			this.id = 5000 + id;
			super(MSGS[id], this.id);
		}
		
		public function toString():String{
			var msg:String = "";
			if(statename != null)msg += "State name: " + statename + " ";
			if(nodename != null)msg += "Node name: " + nodename + " :: ";
			return msg += message;
		}
	}
}